package com.zt.ztzx.controller;

import com.github.pagehelper.PageInfo;
import com.zt.ztzx.model.entity.device.DeviceGather;
import com.zt.ztzx.model.entity.system.SysRole;
import com.zt.ztzx.model.vo.DeviceVo;
import com.zt.ztzx.model.vo.common.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("deviceGather")
public class DeviceGatherController {

    @Autowired
    private com.zt.ztzx.service.DeviceGatherService deviceGatherService;

    @GetMapping("/findAll/{pageNum}/{pageSize}")
    @Operation(summary = "设备采集数据列表", description = "设备采集数据列表",method = "findAll方法")
    @Parameters({
            @Parameter(name = "tid",description = "设备类型ID",required = true),
            @Parameter(name = "pageNum",description = "当前页码",required = true),
            @Parameter(name = "pageSize",description = "每页显示条数",required = true)
    })
    public Result<PageInfo<DeviceVo>> getDeviceGatherList(Integer tid, @PathVariable("pageNum")Integer pageNum, @PathVariable("pageSize")Integer pageSize){
        return deviceGatherService.getDeviceGatherList(tid,pageNum,pageSize);
    }

    @DeleteMapping("/remove")
    @Operation(summary = "删除采集数据",description = "删除采集数据",method = "remove方法")
    @Parameters({
            @Parameter(name = "id",description = "采集数据id",required = true)
    })
    public Result remove(Integer id) {
        return deviceGatherService.removeData(id);
    }

    @PutMapping("/update")
    @Operation(summary = "修改采集数据",description = "修改采集数据",method = "update方法")
    @Parameters({
            @Parameter(name = "deviceGather",description = "采集数据信息",required = true)
    })
    public Result update(@RequestBody DeviceGather deviceGather){
        return deviceGatherService.updateData(deviceGather);
    }
}
